package com.sptpc.drink.controller;

import com.sptpc.drink.service.DrinkService;
import com.sptpc.drink.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/drink")
public class DrinkController {

    @Autowired
    private DrinkService drinkService;

    @GetMapping(value = "/")
    public ServerResponse queryAll(){
        return ServerResponse.createBySuccess(drinkService.queryAll());
    }

    @GetMapping(value = "/{id}")
    public ServerResponse queryById(@PathVariable("id") long id){
        return  ServerResponse.createBySuccess("成功",drinkService.queryById(id));
    }

    @GetMapping(value = "/",params = "name")
    public ServerResponse queryByName(@RequestParam String name){
        return  ServerResponse.createBySuccess("成功",drinkService.queryByName(name));
    }

}
